class MinStack {
public:
    /** initialize your data structure here. */
    MinStack() {}
    
    void push(int x) {
        _Stack.push(x);
        //辅助栈为空 或者 插入元素小于等于栈顶
        if(_minStack.empty()||_minStack.top()>=x)
        {
            _minStack.push(x);
        }
    }
    
    void pop() {
        if(_minStack.top()==_Stack.top())//若出栈元素恰为辅助栈栈顶，则辅助栈也要出更新最小值
        {
            _minStack.pop();
        }
        _Stack.pop();
    }
    
    int top() {
        return _Stack.top();
    }
    
    int min() {
        return _minStack.top();//辅助栈非递增方式存储，栈顶为最小值
    }
private:
    stack<int>_minStack;
    stack<int>_Stack;
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack* obj = new MinStack();
 * obj->push(x);
 * obj->pop();
 * int param_3 = obj->top();
 * int param_4 = obj->min();
 */